import { Component, OnInit } from '@angular/core';
import {Product, ProductService} from '../../../service/product/product.service';

@Component({
  selector: 'app-product3',
  templateUrl: './product3.component.html',
  styleUrls: ['./product3.component.css']
})
export class Product3Component implements OnInit {

  product: Product;

  /*ProductService 是令牌 找出对应的实例化对象 这里返回的AnotherProductService 而不是AppModule对应的ProductService 对象*/
  constructor(private productService: ProductService) {
  }

  ngOnInit() {
    this.product = this.productService.getProduct();
  }
}
